package com.wc.AlgoOJ_train.train1.c0.A015;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/12/25 11:13
 * @description 人见人爱A+B
 * http://43.138.190.70:8888/p/A015
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            int[] day = new int[3];
            day[0] = sc.nextInt();
            day[1] = sc.nextInt();
            day[2] = sc.nextInt();
            day[0] += sc.nextInt();
            day[1] += sc.nextInt();
            day[2] += sc.nextInt();
            day[1] += day[2] / 60;
            day[2] = day[2] % 60;
            day[0] += day[1] / 60;
            day[1] = day[1] % 60;
            System.out.println(day[0] + " " + day[1] + " " + day[2]);
        }
    }
}
